package org.jin.samples.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

public class MD5Utils {
	
/*	public static String GetMD5Code(String strObj){
		
		String resultString = null;
	try{
		resultString = new String(strObj);
		MessageDigest md = MessageDigest.getInstance("MD5");
		resultString = byteToString(md.digest(strObj.getBytes());
	}catch(NoSuchAlgorithmException ex){
		ex.printStackTrace();
	}
	return resultString;
}*/
	
	public static String GetMD5Code(String password) throws NoSuchAlgorithmException{
		MessageDigest md = MessageDigest.getInstance("MD5");
		byte[] temp = md.digest(password.getBytes());
		BASE64Encoder encoder = new BASE64Encoder();
		return encoder.encode(temp);
	}
}
